package com.chinasofti.map;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Demo01 {
    public static void main(String[] args) {
        Map<String, String> map = new HashMap<>();
        map.put("k1", "v1");
        map.put("k2", "v2");
        map.put("k3", "v3");
        map.put("k4", "v4");
//        method1(map);
        method2(map);


    }

    private static void method2(Map<String, String> map) {
        Set<Map.Entry<String, String>> entrySet = map.entrySet();
        System.out.println(entrySet);
        for (Map.Entry<String, String> str:entrySet){
            String k = str.getKey();
            String v = str.getValue();
            System.out.println(k+"--"+v);
        }
    }

    private static void method1(Map<String, String> map) {
        Set<String> stringSet = map.keySet();
        for (String str : stringSet){
            String v = map.get(str);
            System.out.println(str+"--"+v);
        }
    }
}
